
#include "incs.h"

#include "Process.h"

Process::Process( int type /*= 0*/ ) :	
mPaused(false),
mFinished(false),
mSuccessful(false),
mInitialized(false),
mAttached(false),
mType(type)
{

}

Process::~Process()
{

}

void Process::Finish( bool success /*= true*/ )
{
	if(!mFinished) 
	{ 
		mFinished = true; 
		mSuccessful = success; 
	}
}

bool Process::IsSuccessful() const
{
	return mSuccessful;
}

bool Process::IsInitialized() const
{
	return mInitialized;
}

bool Process::IsAttached() const
{
	return mAttached;
}

int Process::GetType() const
{
	return mType;
}

void Process::OnUpdate( int delta )
{

}

bool Process::IsPaused() const
{
	return mPaused;
}

void Process::Pause( bool pause )
{
	if(pause == mPaused) 
		return;

	mPaused = !mPaused;

	if(mPaused == true)
		OnPause();
	else
		OnResume();
}

bool Process::IsFinished() const
{
	return mFinished;
}

void Process::AddNext( Ptr nextProc, bool dependsOnSuccess /*= false*/ )
{
	if(dependsOnSuccess)
		mDepOnSuccess.push_back(nextProc);
	else
		mDepOnFinish.push_back(nextProc);
}

ProcessList const & Process::GetNextList( bool dependsOnSuccess /*= false*/ )
{
	if(dependsOnSuccess)
		return mDepOnSuccess;
	else
		return mDepOnFinish;
}

bool Process::IsActive() const
{
	return mAttached && !mFinished && !mPaused;
}

void Process::OnPause()
{

}

void Process::OnResume()
{

}

void Process::OnInitialize()
{

}

void Process::OnFinish()
{

}